USE [StockSharkDB]
GO


IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[BrokerageAccounts_aspnet_Users]') AND parent_object_id = OBJECT_ID(N'[dbo].[BrokerageAccounts]'))
ALTER TABLE [dbo].[BrokerageAccounts] DROP CONSTRAINT [BrokerageAccounts_aspnet_Users]
GO

ALTER TABLE [dbo].[BrokerageAccounts]  WITH CHECK ADD  CONSTRAINT [BrokerageAccounts_aspnet_Users] FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[BrokerageAccounts] CHECK CONSTRAINT [BrokerageAccounts_aspnet_Users]
GO


IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[WatchedInstruments_aspnet_Users]') AND parent_object_id = OBJECT_ID(N'[dbo].[WatchedInstruments]'))
ALTER TABLE [dbo].[WatchedInstruments] DROP CONSTRAINT [WatchedInstruments_aspnet_Users]
GO

ALTER TABLE [dbo].[WatchedInstruments]  WITH CHECK ADD  CONSTRAINT [WatchedInstruments_aspnet_Users] FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[WatchedInstruments] CHECK CONSTRAINT [WatchedInstruments_aspnet_Users]
GO

